import en from './en.localize.js';
import zhcn from './zh-cn.localize.js';
import zhhk from './zh-hk.localize.js';

class GHLocalize {
  static shareInstance() {
    if (!this.instance) {
      this.instance = new GHLocalize();
    }
    return this.instance;
  }

  constructor() {
    this.code = 'zh';
    this.localize = zhcn;
  }

  getLocalize(lan = 'zh') {
    this.code = lan;

    if (this.code === 'zh' || this.code === 'zh-CN') {
      this.localize = zhcn;
    }
    else if (this.code === 'zh_TW' || this.code === 'zh_HK') {
      this.localize = zhhk;
    }
    else {
      this.localize = en;
      this.code = 'en';
    }

    return this.localize;
  }
}

export default GHLocalize.shareInstance();